﻿@model COMCMS.Core.ArticleCategory
@{
    ViewBag.title = Model.KindName;
    ViewBag.keywords = Model.Keyword;
    ViewBag.description = Model.Description;
    //获取同级分类
    IList<ArticleCategory> sameList = ArticleCategory.FindAll(ArticleCategory._.PId == Model.PId, ArticleCategory._.Rank.Asc(), null, 0, 0);
    int topkid = Model.PId > 0 ? Model.PId : Model.Id;
}

<div class="banner normal sec-banner">
    @if (string.IsNullOrEmpty(Model.BannerImg))
    {
        <em style="background: url('/images/default/slide-1.jpg') center top no-repeat; background-size: 100%;"></em>
    }
    else
    {
        <em style="background: url('@Model.BannerImg') center top no-repeat; background-size: 100%;"></em>
    }
</div>
<!-- mb banner -->
<div class="banner mobile sec-banner">
    @if (string.IsNullOrEmpty(Model.BannerImg))
    {
        <em style="background: url('/images/default/slide-1.jpg') center top no-repeat; background-size: 100%;"></em>
    }
    else
    {
        <em style="background: url('@Model.BannerImg') center top no-repeat; background-size: 100%;"></em>
    }
</div>
@if (Model.PId > 0)
{
    <div class="sec-nav">
        <div class="cont">
            <ul class="sec-nav-list">
                @foreach (var k in sameList)
                {
                    <li class="@(k.Id == Model.Id?"sec-on":"")"><a asp-controller="Article" asp-action="Index" asp-route-id="@(k.Id)" title="@k.KindName">@k.KindName</a></li>
                }
            </ul>

            <script type="text/javascript">
                function mbSecNav() {
                    var num = $('.sec-nav-list li').length;
                    if (num >= 3) {
                        $('.sec-nav-list li').css({ 'width': (640 / 3 / 100) + 'rem' });
                    } else if (num == 2) {
                        $('.sec-nav-list li').css({ 'width': (640 / 2 / 100) + 'rem' });
                    } else if (num == 1) {
                        $('.sec-nav-list li').css({ 'width': (213 / 100) + 'rem' });
                    }
                }
            </script>
        </div>
    </div>
}

<div class="content newsC">
    <div class="news-bg">
        <div class="cont">
            <ul class="news-list" id="listComment">
                @foreach (Article a in ViewBag.list)
                {
                    <li>
                        <a asp-controller="Article" asp-action="Detail" asp-route-id="@(a.Id)" title="@a.Title">
                            @if (!string.IsNullOrEmpty(a.Pic))
                            {
                                <div class="news-pic">
                                    <div class="pic-box">

                                        <img src="@a.Pic" alt="@a.Title">
                                    </div>
                                </div>
                            }

                            <div class="news-text">
                                <span>@a.Title</span>
                                <p>@Utils.CutString(Utils.NoHTML(a.Content), 200)</p>
                                <small>@a.AddTime.ToString("yyyy-MM-dd HH:mm")</small>
                                <b class="normal">查看详情</b>
                            </div>
                        </a>
                    </li>
                }
                @if (ViewBag.list == null || ViewBag.list.Count < 1)
                {
                    <li>暂无相关记录...</li>
                }
            </ul>
            <!-- 分页按钮 -->
            <div class="normal">
                @Html.Raw(Pages.GetPageStr(ViewBag.pagesize, (int)ViewBag.totalCount, ViewBag.page, $"/Article/Index/{Model.Id}" + "?page={0}", 99, 10, ""))
            </div>
            <!-- 点击加载更多 -->
        </div>
    </div>
</div>

<script>
    $(function () {
        $("#nav_@(topkid)").addClass("nav-on");
    })
</script>